package com.jackchong.utils;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;

import com.chad.library.adapter.base.entity.node.BaseNode;
import com.chad.library.adapter.base.provider.BaseNodeProvider;
import com.chad.library.adapter.base.util.AdapterUtilsKt;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;

/**
 * author : chong.huang
* create : 5/9/21
 * desc   :
 */
abstract public class JNodeProvider extends BaseNodeProvider {

    protected Activity mActivity;

    @NotNull
    @Override
    public JRAdapter.ViewHolder onCreateViewHolder(@NotNull ViewGroup parent, int viewType) {
        View itemView = AdapterUtilsKt.getItemView(parent, getLayoutId());
        JAuto.auto(itemView);
        mActivity = (Activity) parent.getContext();
        return new JRAdapter.ViewHolder(itemView);
    }

    @Override
    final public void convert(@NotNull BaseViewHolder baseViewHolder, BaseNode baseNode) {
        convert(((JRAdapter.ViewHolder) baseViewHolder), baseNode);
    }

    public abstract void convert(JRAdapter.ViewHolder holder, BaseNode item);

}
